<!DOCTYPE html>
<html xmlns:render-fun="http://www.w3.org/1999/xhtml">
<head>
    <title>我的游记</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/userTravels.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>


    <script>
        //我的游记页面渲染
        $(function () {
            var userStr = sessionStorage.getItem("user");
            var userJSON = JSON.parse(userStr);

            //记录当前页
            var currentPage = 1;
            //总页数
            var totalPage;
            var dataList = [];

            //先查询第一页游记的记录
            $.get("/tour/listAll", {currentPage: currentPage, pageSize: 8, userId: userJSON.id}, function (data) {
                console.log(data.list);
                $.merge(dataList, data.list)
                $(".travels").renderValues({list: dataList}, {
                    //Jrender在遍历时 有render-fun这个属性会解析 并且调用里面的函数
                    setHref: function (ele, val) {
                        var href = $(ele).attr("data-href") + val;
                        console.log(href);
                        $(ele).attr("data-href", href);
                    }
                });
                currentPage += 1;
                totalPage = data.pages;
            })

            //location.href = url + params.id + '&dealId=' + data.data;
            //屏幕滚动判断+翻页
            $(window).scroll(function () {
                if ($(window).height() + $(window).scrollTop() >= $(document).height()) {
                    if (currentPage <= totalPage) {
                        $.get("/tour/listAll", {
                            currentPage: currentPage,
                            pageSize: 8,
                            userId: userJSON.id
                        }, function (data) {
                            $.merge(dataList, data.list);
                            $(".travels").renderValues({list: dataList}, {
                                setHref: function (ele, val) {
                                    var href = $(ele).attr("data-href") + val;
                                    $(ele).attr("data-href", href);
                                }
                            });
                            currentPage += 1;
                        })
                    } else {
                        $(document).dialog({
                            autoClose: 2500,
                            content: "我是个有底线的人",
                        });
                    }
                }
            })

            $(".travels").on("click", ".see", function () {
                var dest = $(this).data("href")
                console.log($(this).data("id"));
                var state = $(this).data("id")
                if (state == 1) {
                    console.log("付款");
                    window.location.href = dest
                }
                //直接进行跳转,假如状态还是未付款
            })


        })

    </script>


</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="profiles.html">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>还未到期的订单信息</span>
        </div>
        <div class="col"></div>
    </div>
</div>


<div class="container travels">
    <dl class="list" render-loop="list">
        <dd id="pills-tab">
            <a class="see" data-href="/mine/payfortravel.html?id=" render-fun="setHref" render-key="list.url"
               render-attr="data-id=list.state">
                <h6 class="title" render-html="list.ticketName"></h6>
                <p>姓名: <span render-html="list.name"></span>
                    游玩时间: <span render-html="list.playTime"></span><br/>
                    订单金额: <span render-html="list.realDel"></span>
                    <span class="span-right">
							  <i class="fa fa-money"></i><span render-html="list.stateDisplay">0</span>
						  </span>
                </p>

            </a>
        </dd>
    </dl>
</div>

</body>
</html>
